Add a filter hook for the theme style variations #63607
Open
+47
−15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #63574
What?
This PR adds filter hooks to allow for custom style variations to be injected and additional directories to be scanned for JSON files. Specifically, it introduces:
Why?
Currently, only themes can register theme style variations by adding JSON files to their /styles folder. There is no API or filter hook to add custom variations outside of using the /styles folder. This PR addresses this limitation by providing the necessary hooks to extend and customize style variations more flexibly.
How?
wp_theme_json_style_variation_directories
is added to allow custom directories to be included when scanning for style variation JSON files.wp_theme_json_variation_files
is added to enable plugins to modify the array of style variation files collected from the directories.Testing Instructions
custom-styles
in the root of your plugin and add a JSON file with style variations.Screenshots or screencast
New Styles
variations added by newcustom-styles
folder usingwp_theme_json_style_variation_directories
filterwp_theme_json_variation_files
filter